#{extends '/template/main.html' /}
<!-- Removing search and results count filter -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">全部用户</h3>

        <div class="panel-options">
            <a href="/power/admin/AdminUserCtrl/loadUserDetail">
                <button class="btn btn-success btn-icon">
                    <i class="fa-plus-square-o"></i>
                    <span>新建用户</span>
                </button>
            </a>
        </div>
    </div>
    <div class="panel-body">
        <form method="get" id="searchForm" action="/power/admin/AdminUserCtrl/loadUserList/${pageNumber}">
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="name" id="name" class="form-control" style="width:150px" placeholder="用户名称" value="${name}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="loginName" id="loginName" class="form-control" style="width:150px" placeholder="登录名称" value="${loginName}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="phoneNo" id="phoneNo" class="form-control" style="width:150px" placeholder="联系电话" value="${phoneNo}">
            </div>

            <div style="margin-bottom: 20px;width:160px;float: left;">
                <select name="merchantId" id="merchantId" class="form-control" style="width:150px" data-style="btn-primary">
                    <option value="" #{if merchantId == null} selected="true"#{/if}>---场馆---</option>
                    #{list merchantList ,as :'merchant'}
                    <option value="${merchant.id}"  #{if merchantId == merchant.id } selected="true"#{/if}>${merchant.name}</option>
                    #{/list}
                </select>
            </div>

        </form>
        <button class="btn btn-turquoise" id="searchBtn">开始检索</button>
        <table class="table table-bordered table-striped" id="example-2">
            <thead>
            <tr>
                *{<th class="no-sorting">}*
                    *{<input type="checkbox" class="cbr">}*
                *{</th>}*
                <th>用户名称</th>
                <th>登录名</th>
                <th>联系电话</th>
                <th>所属场馆</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody class="middle-align">
            #{paginate.list items:resultPage , as :'user'}
            <tr>
                *{<td>}*
                    *{<input type="checkbox" class="cbr">}*
                *{</td>}*
                    <td>${user?.name}</td>
                    <td>${user?.loginName}</td>
                    <td>${user?.phoneNo}</td>
                    <td>${user?.merchant?.name}</td>
                <td>
                    <a href="/power/admin/AdminUserCtrl/loadUserDetail/${user?.id}/${pageNumber}" class="btn btn-secondary btn-sm btn-icon icon-left">编辑</a>

                    <a href="#" id="idBtnDel" onclick="deletedComfim(${user?.id});" class="btn btn-danger btn-sm btn-icon icon-left">删除</a>
                </td>
            </tr>
            #{/paginate.list}

            </tbody>
        </table>
        <div id="layerPage" class="col-xs-12"></div>
    </div>
</div>



<!-- Imported styles on this page -->
<link rel="stylesheet" href="/public/js/datatables/dataTables.bootstrap.css">

<script src="/public/js/datatables/js/jquery.dataTables.min.js"></script>


<!-- Imported scripts on this page -->
<script src="/public/js/datatables/dataTables.bootstrap.js"></script>
<script src="/public/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
<script src="/public/js/datatables/tabletools/dataTables.tableTools.min.js"></script>

<script type="text/javascript" src="/public/laypage/laypage.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        // 提示
        var msg = '${flash.get("msg")}';
        if(msg) {
            saveSuccess(msg);
        }

        // 分页
        laypage({
            cont: $('#layerPage'), //容器。值支持id名、原生dom对象，jquery对象,
            pages: '${resultPage?.pageCount}', //总页数
            skin: 'yahei',
            curr:'${pageNumber}',
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    $('#pageNumber').val(e.curr);
                    $("#searchForm").attr("action", "/power/admin/AdminUserCtrl/loadUserList/"+e.curr);
                    $('#searchForm').submit();
                }
            }
        });
        $(document).on("click", "#searchBtn", function(){
            $("#searchForm").attr("action", "/power/admin/AdminUserCtrl/loadUserList/1");
            $('#searchForm').submit();
        })

    });


    //点击确认删除 之后执行的方法
    function sureDeleted() {
        //获取删除的id
        var id = $('#deleteId').val();
        document.location.href='/power/admin/AdminUserCtrl/deletedAdminUser/'+id+'/${pageNumber}';
    }


</script>


